package com.tencent.sr.iris.basic.saas.dependency.activity;

import com.tencent.sr.iris.activity.interfaces.client.activity.ActivityConfigClient;
import com.tencent.sr.iris.activity.interfaces.request.IrisPaginationRequest;
import com.tencent.sr.iris.activity.interfaces.request.acticity.ActivityMonthLimitAddRequest;
import com.tencent.sr.iris.activity.interfaces.request.acticity.ActivityUidLimitAddRequest;
import com.tencent.sr.iris.activity.interfaces.request.acticity.ActivityUidLimitPageRequest;
import com.tencent.sr.iris.activity.interfaces.request.acticity.ActivityUidLimitUpdateRequest;
import com.tencent.sr.iris.activity.interfaces.response.activity.ActivityMonthLimitResponse;
import com.tencent.sr.iris.activity.interfaces.response.activity.ActivityUidLimitResponse;
import com.tencent.sr.iris.basic.saas.common.utils.HttpUtils;
import com.tencent.sr.rmall.common.primitive.HttpResult;
import com.tencent.sr.rmall.common.request.PaginationRequest;
import com.tencent.sr.rmall.common.response.PaginationResponse;
import com.tencent.sr.rmall.springbootstarter.authtoken.localbean.AppUser;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;


@Component
@Slf4j
public class ActivityConfigDependency {

    @Resource
    private ActivityConfigClient activityConfigClient;

    @Resource
    private AppUser appUser;

    public PaginationResponse<ActivityMonthLimitResponse> monthLimitConfigPage(PaginationRequest request) {
        HttpResult<PaginationResponse<ActivityMonthLimitResponse>> result = activityConfigClient.monthLimitConfigPage(request);
        return HttpUtils.handleResult(result);
    }

    public PaginationResponse<ActivityUidLimitResponse> uidLimitConfigPage(
            IrisPaginationRequest<ActivityUidLimitPageRequest> request) {
        HttpResult<PaginationResponse<ActivityUidLimitResponse>> result = activityConfigClient.uidLimitConfigPage(request);
        return HttpUtils.handleResult(result);
    }

    public Boolean addCurrentMonthLimit(ActivityMonthLimitAddRequest request) {
        request.setOperatorUid(appUser.getUid());
        HttpResult<Boolean> result = activityConfigClient.addCurrentMonthLimit(request);
        return HttpUtils.handleResult(result);
    }

    public Boolean addUidLimit(ActivityUidLimitAddRequest request) {
        request.setOperatorUid(appUser.getUid());
        HttpResult<Boolean> result = activityConfigClient.addUidLimit(request);
        return HttpUtils.handleResult(result);
    }

    public Boolean updateUidLimit(ActivityUidLimitUpdateRequest request) {
        request.setOperatorUid(appUser.getUid());
        HttpResult<Boolean> result = activityConfigClient.updateUidLimit(request);
        return HttpUtils.handleResult(result);
    }
}
